package br.ufrn.btest.decorators.predicates;

import java.util.HashSet;
import java.util.Set;

import br.ufrn.btest.decorators.expressions.MyExpression;
import br.ufrn.btest.decorators.expressions.MyExpressionFactory;
import de.be4.classicalb.core.parser.node.AIncludePredicate;
import de.be4.classicalb.core.parser.node.PPredicate;

public class MyAIncludePredicate extends MyPredicateDecorator{

	
	private AIncludePredicate includePredicate;
	private MyExpression leftExpression;
	private MyExpression rightExpression;

	
	public MyAIncludePredicate(AIncludePredicate includePredicate) {
		this.includePredicate = includePredicate;
		this.leftExpression = MyExpressionFactory.convertExpression(includePredicate.getLeft());
		this.rightExpression = MyExpressionFactory.convertExpression(includePredicate.getRight());
	}
	
	
	
	public MyExpression getLeftExpression() {
		return this.leftExpression;
	}
	
	
	
	public MyExpression getRightExpression() {
		return this.rightExpression;
	}
	
	
	
	@Override
	public PPredicate getNode() {
		return this.includePredicate;
	}
	
	
	
	@Override
	public String toString() {
		return getLeftExpression().toString() + " <: " + getRightExpression().toString();
	}

	
	
	@Override
	public void createClausesList(Set<MyPredicate> clauses) {
		clauses.add(this);
	}

	
	
	@Override
	public Set<String> getVariables() {
		HashSet<String> variables = new HashSet<String>();
		variables.addAll(getLeftExpression().getVariables());
		variables.addAll(getRightExpression().getVariables());
		return variables;
	}
	
	
	
	@Override
	public boolean isTypingClause() {
		if(getRightExpression().isBasicType()) {
			return true;
		} else {
			return false;
		}
	}

	
	
	@Override
	public boolean isInterval() {
		if (getRightExpression().isInterval()) {
			return true;
		} else {
			return false;
		}
	}
	
}
